package drds.server.sqlparser.visitor;

import drds.server.sqlparser.sqlobject.expression.InList;
import drds.server.sqlparser.sqlobject.expression.binary.BinaryExpression;
import drds.server.sqlparser.sqlobject.expression.data_type.Null;
import drds.server.sqlparser.sqlobject.expression.data_type.Text;
import drds.server.sqlparser.sqlobject.expression.data_type.number.Decimal;
import drds.server.sqlparser.sqlobject.expression.data_type.number.Int;

/**
 * 
 * @author 曹正辉<330937205@qq.com>
 * 
 */
public class ParameterizedOutputVisitor extends OutputVisitor implements ParameterizedVisitor {

	private int replaceCount;

	public ParameterizedOutputVisitor() {
		this(new StringBuilder());
	}

	public ParameterizedOutputVisitor(Appendable appender) {
		super(appender);
	}

	public int getReplaceCount() {
		return this.replaceCount;
	}

	public void incrementReplaceCunt() {
		replaceCount++;
	}

	public boolean visit(InList x) {
		return ParameterizedOutputVisitorUtils.visit(this, x);
	}

	public boolean visit(BinaryExpression x) {
		x = ParameterizedOutputVisitorUtils.merge(this, x);

		return super.visit(x);
	}

	public boolean visit(Int x) {
		if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
			return super.visit(x);
		}

		return ParameterizedOutputVisitorUtils.visit(this, x);
	}

	public boolean visit(Decimal x) {
		if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
			return super.visit(x);
		}

		return ParameterizedOutputVisitorUtils.visit(this, x);
	}

	public boolean visit(Text x) {
		if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
			return super.visit(x);
		}

		return ParameterizedOutputVisitorUtils.visit(this, x);
	}

	public boolean visit(Null x) {
		if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
			return super.visit(x);
		}

		return ParameterizedOutputVisitorUtils.visit(this, x);
	}

}
